package com.maoyanjava.controller;

import com.alibaba.fastjson.JSON;
import com.maoyanjava.pojo.Film;
import com.maoyanjava.service.FilmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
public class FilmController {
    @Autowired
    private FilmService fs;

    //全部电影
    @GetMapping("/AllFilm")
    public List<Film> getAllFilm(HttpServletRequest request, HttpServletResponse response){
        List<Film> f = fs.getAllFilm();
        System.out.println(f);
        return f;
    }
    //type-f-2 类查找：
    @GetMapping("/ClassFilm")
    public List<Film> getClassFilm(HttpServletRequest request, HttpServletResponse response){
        String name = request.getParameter("name");
        List<Film> f = fs.getClassFilm(name);
        System.out.println(f);
        return f;
    }
    //热映
    @GetMapping("/TimeFilm")
    public List<Film> getTimeFilm(HttpServletRequest request, HttpServletResponse response){
        String i = request.getParameter("i");
        int i1 = Integer.parseInt(request.getParameter("i"));
        System.out.println(i);
        System.out.println(i1);
        List<Film> f = fs.getTimeFilm(i1);
        System.out.println(f);
        return f;
    }
}
